package com.jackiechan.idol;

import javax.security.auth.login.LoginContext;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
//        func();
        show();
    }

    public static void show() {
        String str = " fal fda ";
        System.out.println(str.substring(2, 6));
        System.out.println(str.charAt(2));
    }

    public static void func() {
        System.out.println("请输入用户名:");
        String name = new Scanner(System.in).nextLine();
        System.out.println("请输入密码:");
        String pwd = new Scanner(System.in).nextLine();
        try {
            login(name, pwd);
            System.out.println("欢迎登录");
        } catch (UserNameNFException e) {
            System.out.println("用户名错误");
        } catch (pwdNFException e) {
            System.out.println("密码错误");
        }
    }

    public static void login(String name, String pwd)
            throws UserNameNFException, pwdNFException {
        if (!name.equals("jackiechan")) {
            throw new UserNameNFException();
        }
        if (!pwd.equals("19540407")) {
            throw new pwdNFException();
        }
    }
}

class UserNameNFException extends Exception {
    public UserNameNFException() {
        super();
    }

    public UserNameNFException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public UserNameNFException(String message, Throwable cause) {
        super(message, cause);
    }

    public UserNameNFException(String message) {
        super(message);
    }

    public UserNameNFException(Throwable cause) {
        super(cause);
    }
}

class pwdNFException extends Exception {
    public pwdNFException() {
        super();
    }

    public pwdNFException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public pwdNFException(String message, Throwable cause) {
        super(message, cause);
    }

    public pwdNFException(String message) {
        super(message);
    }

    public pwdNFException(Throwable cause) {
        super(cause);
    }
}
